<template>
	<view class="shoukuanCon">
		<uni-nav-bar left-icon="arrowthinleft" title="收款码" :border="false" bg="bg-zhuse" color="#fff"  @clickLeft="goBack()"></uni-nav-bar>
		<view class="jui_main">
			<view class="skCon ">
				<view class="fs-30 color-333 text-center tit">扫一扫 向我转账</view>
				<image :src="codeImg"></image>
				<view class="btn" @tap="saveImg()">保存图片</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				codeImg:''
			}
		},
		onShow() {
			this.getInfo()
		},
		methods:{
			getInfo(){
				var that = this;
				that.$api.collection_code().then(res => {
					if(res.code == 1){
						that.codeImg = res.data.qrcode
					}
				});
			},
			// 保存海报
			saveImg() {
				var that = this;
				var shareImg = that.codeImg;
				uni.downloadFile({
					//下载图片
					url: shareImg,
					success: res => {
						console.log(res.tempFilePath);
						uni.saveImageToPhotosAlbum({
							//将图片保存在手机
							filePath: res.tempFilePath, //保存的位置
							success: res => {
								that.$msg('保存成功');
							}
						});
					}
				});
				
			},
		}
	}
</script>

<style lang="scss">
	page{background: #FF932E;}
	.shoukuanCon{
		.jui_main{padding-left: 40rpx;padding-right: 40rpx;overflow: hidden;
			.skCon{height: 780rpx;background: url('../../static/img/sk.png') no-repeat;background-size: 100% 100%;margin-top: 80rpx;}
			.tit{line-height: 150rpx;border-bottom: 1rpx dashed #eee;margin-left: 20rpx;margin-right: 20rpx;}
			image{width: 360rpx;height: 360rpx;display: block;margin: 88rpx auto 0;}
		}
	}
	.btn{width: 260rpx;height: 66upx;line-height: 66upx; border-radius: 40upx;text-align: center;background: $uni-color-zhuse;color: #fff;margin:60upx auto;}
</style>
